home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Applications
/
PICSee Dust 1.01
/
Quaternary Source
/
KeyUtils.cpp
< prev
next >
Wrap
Text File
|
1995-11-08
|
1KB
|
67 lines
/*
KeyUtils.c++
Written by Hiep Dam.
Last Update: Sept. 1994
*/
#include "KeyUtils.h"
Boolean IsKeyDown(unsigned short theKey);
Boolean IsKeyDown(unsigned short theKey)
// theKey = any keyboard scan code, 0-127
{
unsigned char km[16];
GetKeys(*((KeyMap*) &km));
return ((km[theKey>>3] >> (theKey & 7)) & 1);
}
Boolean CmdKeyDown() {
return IsKeyDown(0x37);
}
Boolean OptionKeyDown() {
return IsKeyDown(0x3A);
}
Boolean ShiftKeyDown() {
return IsKeyDown(0x38);
}
Boolean CapsKeyDown() {
return IsKeyDown(0x39);
}
Boolean ControlKeyDown() {
return IsKeyDown(0x3B);
}
Boolean SpaceKeyDown() {
return IsKeyDown(0x31);
}
Boolean TabKeyDown() {
return IsKeyDown(0x30);
}
// ---------------------------------------------------------------------------
Boolean StrNumberOnly(Str255 theStr, Boolean includePeriod, Boolean includeComma) {
Boolean numOnly = true;
for (short i = 1; i <= theStr[0]; i++) {
if (theStr[i] >= '0' && theStr[i] <= '9') {
}
else if (includePeriod && theStr[i] == '.') {
}
else if (includeComma && theStr[i] == ',') {
}
else if (theStr[i] == '+' || theStr[i] == '-') {
}
else {
numOnly = false;
break;
}
}
return(numOnly);
} // END StrNumberOnly